package com.tedu.egcqmvcboot.interceptor;


import com.tedu.egcqmvcboot.pojo.vo.UserVO;
import org.springframework.web.servlet.HandlerInterceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        UserVO user = (UserVO) request.getSession().getAttribute("user");
        if (user==null){
            response.sendRedirect("/index.html");//重定向
            return false;
        }else{
            return true;
        }
    }


}
